home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 September / Macworld (1998-09).dmg / Shareware World / Info / For Developers / MacZoop 1.8.3 / More Classes / File Classes / ZPrefsFile.cpp < prev    next >
Text File  |  1998-05-13  |  1KB  |  77 lines

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            MacZoop - "the framework for the rest of us"             
  5. *
  6. *
  7. *
  8. *            ZPrefsFile.cpp            -- the prefs file object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22. #include    "ZPrefsFile.h"
  23. #include    "MacZoop.h"
  24.  
  25. #include    <folders.h>
  26.  
  27. static FSSpec    gDummySpec = { 0, 0, "\p" };
  28.  
  29.  
  30. ZPrefsFile::ZPrefsFile( Str255 fName )
  31.     : ZResourceFile( gDummySpec )
  32. {
  33.     short    foundVR;
  34.     long    dirID;
  35.     OSErr    theErr;
  36.     
  37.     itsType = kPrefsFileType;
  38.     
  39.     FailOSErr( FindFolder( kOnSystemDisk, kPreferencesFolderType, TRUE, &foundVR, &dirID ));
  40.     
  41.     theErr = FSMakeFSSpec( foundVR, dirID, fName, &itsSpec );
  42.     
  43.     if ( theErr == fnfErr )
  44.         CreateResFork();
  45.     else
  46.         FailOSErr( theErr );
  47. }
  48.  
  49.  
  50.  
  51. ZPrefsFile::ZPrefsFile()
  52.     : ZResourceFile( gDummySpec )
  53. {
  54.     short    foundVR;
  55.     long    dirID;
  56.     OSErr    theErr;
  57.     
  58.     itsType = kPrefsFileType;
  59.  
  60.     FailOSErr( FindFolder( kOnSystemDisk, kPreferencesFolderType, TRUE, &foundVR, &dirID ));
  61.     
  62.     // make the filename by using the app's name and appending "prefs" (STR#128/16)
  63.     
  64.     Str255    fName;
  65.     Str31    pf;
  66.     
  67.     gApplication->GetName( fName );
  68.     GetIndString( pf, 128, 16 );
  69.     ConcatPStrings( fName, pf );
  70.     
  71.     theErr = FSMakeFSSpec( foundVR, dirID, fName, &itsSpec );
  72.     
  73.     if ( theErr == fnfErr )
  74.         CreateResFork();
  75.     else
  76.         FailOSErr( theErr );
  77. }